package com.tinygone.eurekamovie3.controller;

import com.tinygone.eurekamovie3.pojo.Movie;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;


@RestController
@Slf4j
public class UserController {

    @Value("${server.port}")
    private String port;

    @GetMapping("/port")
    public String getPort() {
        return port;
    }


    @GetMapping("/movie/{id}")
    public Movie getMovieById(@PathVariable String id) {
        Movie movie = new Movie(id, "让子弹飞", "姜文");
        movie.setPort(port);
        log.info("getMovieById:{}", movie);
        return movie;
    }

    @PostMapping("/movie/post")
    public Movie moviePost(@RequestBody Movie movie) {
        movie.setPort(port);
        return movie;
    }


}
